unit DesignTimeForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IniFiles;

type
  TForm2 = class(TForm)
    GroupBox1: TGroupBox;
    Label11: TLabel;
    Label10: TLabel;
    LabelTotal: TLabel;
    LabelInvalid: TLabel;
    procedure FormCreate(Sender: TObject);
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.FormCreate(Sender: TObject);
var
  Ini: TIniFile;
  Candidates: TStringList;
  TotalCount, I: Integer;
begin
  Ini := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'config.ini');
  TotalCount := Ini.ReadInteger('COUNTERS', 'Total', 100);
  Candidates := TStringList.Create;
  Ini.ReadSection('CANDIDATES', Candidates);

  for I := 1 to Candidates.Count do
  begin
    with TLabel.Create(Self) do
    begin
      Caption := IntToStr(I) + '. ' + Ini.ReadString('CANDIDATES', IntToStr(I),
        'empty');
      Left := 27;
      Top := 19 * I + 5;
      Width := 120;
      Parent := Sender as TWinControl;
    end;
    with TLabel.Create(Self) do
    begin
      if TotalCount <> 0 then
        Caption := FloatToStr(Trunc(Ini.ReadInteger('COUNTERS', IntToStr(I),
              100) / TotalCount * 100)) + '%'
      else
        Caption := '0%';
      Left := 160;
      Top := 19 * I + 5;
      Width := 120;
      Parent := Sender as TWinControl;
    end;
  end;

  GroupBox1.Height := (Components[ComponentCount - 1] as TLabel).Top + 20;
  LabelTotal.Caption := IntToStr(TotalCount);
  LabelTotal.Top := (Components[ComponentCount - 1] as TLabel).Top + 40;
  Label11.Top := LabelTotal.Top;
  LabelInvalid.Caption := IntToStr(Ini.ReadInteger('COUNTERS', 'Invalid', 100));
  LabelInvalid.Top := LabelTotal.Top + 19;
  Label10.Top := LabelInvalid.Top;
  Height := Label10.Top + 50;

end;

end.
